	
// EnumFag.h : Declaration of the CEnumFag

#ifndef __ENUMFAG_H_
#define __ENUMFAG_H_

#include "resource.h"       // main symbols
#include "importado.h"
#include "fag.h"
#include "karakterskala.h"

/////////////////////////////////////////////////////////////////////////////
// CEnumFag
class ATL_NO_VTABLE CEnumFag : 
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<CEnumFag, &CLSID_EnumFag>,
	public ISupportErrorInfo,
	public IDispatchImpl<IEnumFag, &IID_IEnumFag, &LIBID_EBASDLLLib>
{
public:
	CEnumFag();
	virtual ~CEnumFag();

DECLARE_REGISTRY_RESOURCEID(IDR_ENUMFAG)
DECLARE_NOT_AGGREGATABLE(CEnumFag)
DECLARE_GET_CONTROLLING_UNKNOWN()

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CEnumFag)
	COM_INTERFACE_ENTRY(IEnumFag)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
	COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
END_COM_MAP()

	HRESULT FinalConstruct()
	{
		return CoCreateFreeThreadedMarshaler(
			GetControllingUnknown(), &m_pUnkMarshaler.p);
	}

	void FinalRelease()
	{
		m_pUnkMarshaler.Release();
	}

	CComPtr<IUnknown> m_pUnkMarshaler;

// ISupportsErrorInfo
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

// IEnumFag
public:
	STDMETHOD(findFagGruppe)(/*[in]*/IGruppe * pGruppe);
	STDMETHOD(findFagNavn)(/*[in]*/BSTR navn, /*[out,retval]*/ IFag ** ppFag);
	STDMETHOD(Clone)(/*[out]*/ IEnumeration ** ppEnumeration);
	STDMETHOD(Reset)();
	STDMETHOD(Skip)(/*[in]*/ ULONG cItems);
	STDMETHOD(Next)(/*[out]*/ IUnknown ** ppUnk, /*[out]*/ ULONG * pcFetched);
	STDMETHOD(put_FagNavn)(BSTR navn)
	{
		m_fagNavn = navn;
		return S_OK;
	}
private:
	_RecordsetPtr m_records;
	bool m_first;
	ULONG m_pos;
	ULONG m_length;
	bstr_t m_studGuid;
	bstr_t m_fagNavn;
};

#endif //__ENUMFAG_H_
